﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aleator.Core
{
    /// <summary>
    /// Concrete factory for phrase creation
    /// </summary>
    public class ConcretePhraseFactory : PhraseFactory
    {
        /// <summary>
        /// Create default phrase
        /// </summary>
        /// <returns></returns>
        public override Phrase GetPhrase()
        {
            return new ConcretePhrase();
        }

        /// <summary>
        /// Create the given type of phrase
        /// </summary>
        /// <param name="phrasetype"></param>
        /// <param name="progression"></param>
        /// <param name="phrase"></param>
        /// <returns></returns>
        public override Phrase GetPhrase(PhraseType phrasetype, ConcreteProgression progression, Phrase phrase = null)
        {
            switch (phrasetype)
            {
                case (PhraseType.Drum):
                    return new DrumPhrase(progression, false, (DrumPhrase)phrase);
                case (PhraseType.Bass):
                    return new BassPhrase(progression, (BassPhrase)phrase);
                case (PhraseType.Rhythm):
                    return new RhythmPhrase(progression, (RhythmPhrase)phrase);
                case (PhraseType.Melody):
                    return new MelodyPhrase(progression, (MelodyPhrase)phrase);
                default:
                    return new ConcretePhrase();

                //TODO: Add casses for arp and utility
            }
        }

        /// <summary>
        /// Create a slightly altered version of the provided phrase
        /// </summary>
        /// <param name="phrasetype"></param>
        /// <param name="progression"></param>
        /// <param name="phrase"></param>
        /// <param name="variance"></param>
        /// <returns></returns>
        public override Phrase ExplodePhrase(PhraseType phrasetype, ConcreteProgression progression)
        {
            switch (phrasetype)
            {
                case (PhraseType.Drum):
                    return new DrumPhrase(progression, true);
                default:
                    throw new NotImplementedException("Commonality only implemented for drums.");
            }
        }
    }
}
